/*
 * @Author: your name
 * @Date: 2020-08-18 09:39:54
 * @LastEditTime: 2021-01-29 11:17:06
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \webUI\vue.config.js
 */

'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')

function resolve (dir) {
    return path.join(__dirname, dir)
}

const name = defaultSettings.title || '企业供需精准对接服务' // page title

// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run
// You can change the port by the following methods:
// port = 9528 npm run dev OR npm run dev --port = 9528
const port = process.env.port || process.env.npm_config_port || 81 // dev port

// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {

    // publicPath: './',
    publicPath: '/',
    outputDir: 'dist',
    assetsDir: 'static',
    lintOnSave: false, //代码检测关闭
    productionSourceMap: false,
    devServer: {
        disableHostCheck: true,
        port: port,
        proxy: {
            '/wenge': { //代理api
                // target: "http://172.16.0.6:32375/consumer-web/web/api", //服务器api地址
                target: "http://gyy-web.quesoar.com:20000/", //服务器api地址
                // target: "http://10.204.124.107:8081/web/api", //服务器api地址
                changeOrigin: true, //是否跨域
                logLevel: 'debug',//开启跨域代理调试
            },
            '/bidding': {
                target: "http://10.204.124.226:32270/bidding", //服务器api地址
                changeOrigin: true, //是否跨域
                pathRewrite: { //重写路径
                    "^/bidding": '/'
                }
            },
            '/oauth': {
                target: "http://172.16.0.12:30713/oauth", //服务器api地址
                changeOrigin: true, //是否跨域
                pathRewrite: { //重写路径
                    "^/oauth": '/'
                }
            },
            '/basic-api': {
                //target: "http://123.249.110.85:10240/prod-api", //服务器api地址
                target: "http://localhost:8080", //服务器api地址
                changeOrigin: true, //是否跨域
                pathRewrite: {
                    ['^' + '/basic-api']: ''
                }
            }
        },
    },
    configureWebpack: {
        // it can be accessed in index.html to inject the correct title.
        name: name,
        resolve: {
            alias: {
                '@': resolve('src')
            }
        },
        module: {
            rules: [
                { test: /\.txt$/, use: 'raw-loader' }
            ]
        }
    },

    // devServer: {
    //     disableHostCheck: true
    //   },

    css: {
        loaderOptions: {
            less: {
                lessOptions: {
                    modifyVars: {
                        'primary-color': '#188af1',
                        'link-color': '#188af1',
                        'border-radius-base': '4px',
                    },
                    javascriptEnabled: true,
                },
            },
        },
    },
    pluginOptions: {
        'style-resources-loader': {
            preProcessor: 'less',
            patterns: [
                path.resolve(__dirname, './src/assets/css/theme.less'),
            ],
        },
    },
    chainWebpack: config => {
        config.module
            .rule('vue')
            .use('vue-loader')
            .tap(options => {
                // 修改它的选项...
                return options
            })
    }

}